/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.helper;

import java.util.Set;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.uml2.uml.Element;

import com.cea.papyrus.diagraminterchange2.di2.GraphElement;

// TODO: Auto-generated Javadoc
/**
 * Interface for factories that manage uml elements in the model.
 * 
 * @author Remi Schnekenburger
 */
public interface IModelerHelper {
	
	/**
	 * id for factories not associated to a diagram. Ex: common behavior
	 */
	public final static String NULL_DIAGRAM_ID = "null_diagram";
	
	

	/**
	 * This method create a graphNode and an associated umlElement.
	 * 
	 * @param objectToCreate the Class to create
	 * @param name name of the uml Element to create
	 * @param parent the uml elment parent
	 * if null the element is create at the model level
	 * 
	 * @return the created the uml Element
	 */
	public org.eclipse.uml2.uml.Element createUMLElement(Class objectToCreate,String name, org.eclipse.uml2.uml.Element parent);

	/**
	 * This method create a graphNode and an associated umlElement.
	 * 
	 * @param objectToCreate the Class to create
	 * @param parent the uml elment parent
	 * if null the elment is create at the model level
	 * 
	 * @return the created the uml Element
	 */
	public org.eclipse.uml2.uml.Element createUMLElement(Class objectToCreate, org.eclipse.uml2.uml.Element parent);

	/**
	 * 
	 * 
	 * @param element 
	 * @param objectToCreate 
	 * @param umlParent 
	 * 
	 * @return 
	 */
	public boolean addUMLElement(Class objectToCreate, Element element, Element umlParent);
		
	/**
	 * This method delete the umlElement.
	 * 
	 * @param umlparent the umlparent
	 * @param objectToCreate the Class to delete
	 * @param umlelement the umlelement to delete
	 * 
	 * @return true if the element is deleted
	 */
	public boolean removeElement(Class objectToCreate,org.eclipse.uml2.uml.Element umlelement, org.eclipse.uml2.uml.Element umlparent);

	/**
	 * This method create a graphNode and an associated umlElement.
	 * 
	 * @param umlChild the uml child
	 * @param objectToCreate the Class to create
	 * @param size the size
	 * @param location the location
	 * @param name name of the uml Element to create
	 * @param parent the graphical Node that content the future Element
	 * if null the elment is create a model level
	 * 
	 * @return the created GrahNode
	 */
	public GraphElement createGraphElement(Element umlChild, GraphElement parent, Point location, Dimension size); 
	
	/**
	 * 
	 * 
	 * @param child 
	 * @param objectToCreate 
	 * @param parent 
	 * 
	 * @return 
	 */
	public GraphElement addGraphElement(Class objectToCreate,GraphElement child, GraphElement parent);
		
	/**
	 * 
	 * 
	 * @param child 
	 * @param objectToCreate 
	 * @param parent 
	 * 
	 * @return 
	 */
	public boolean removeGraphElement(Class objectToCreate,GraphElement child, GraphElement parent);
	
	/**
	 * this method is used to know if an graphNode may be add in another.
	 * 
	 * @param objectToCreate the object to create
	 * @param objectToAdd the Class to add
	 * @param parent the graphNodeParent
	 * 
	 * @return true, if can execute
	 */
	public boolean canCreateGraphElement(Class objectToCreate, GraphElement parent);
	
	/**
	 * this method is used to know if an element to a edge may be added between two nodes.
	 * 
	 * @param the target of the edge
	 * *
	 * @param objectToCreate the object to create
	 * @param objectToAdd the Class to add
	 * @param target the target
	 * @param source the source
	 * 
	 * @return true, if can execute
	 */
	public boolean canConnect(Class objectToCreate, Element source,Element target);
	
	
	/**
	 * this method is used to connect two uml Element whit an link.
	 * 
	 * @param type 
	 * @param target the target
	 * @param link the link
	 * @param source the source
	 * 
	 * @return true, if connect
	 */
	public boolean connect(Class type,Element source, Element target, Element link);
	
	
	/**
	 * 
	 * 
	 * @param type 
	 * @param target 
	 * @param link 
	 * @param source 
	 * 
	 * @return 
	 */
	public boolean deconnect(Class type,Element source, Element target, Element link);
	
	 /**
 	 * Returns a unique identifier for this factory, or <code>null</code> if it has
 	 * none.
 	 * 
 	 * @return the factory id, or <code>null</code> if none
 	 */
	public String getId();
	
	
	/**
	 * Returns <code>true</code> if this Factory is able to deal with this kind of element.
	 * 
	 * @param elementClass the metaclass of the element to create or delete
	 * 
	 * @return <code>true</code> if this factory is able to deal with this kind of element
	 */
	public boolean isFactoryFor(Class elementClass);
	
	/**
	 * Returns the Factory that is able to manage this kind of element.
	 * 
	 * @param elementClass the metaclass of the element to create or delete
	 * 
	 * @return the factory that deals with this kind of element
	 */
	public Object getElementFactory(Class elementClass);
	
	/**
	 * Returns all metaclasses that are handled by this factory.
	 * 
	 * @return the set of metaclasses handled by this factory
	 */
	public Set<Class> getDefinedMetaClasses();
}
